package org.smartit.client.navigation;

import com.google.gwt.user.client.ui.Composite;
import org.smartit.client.config.menu.SubMenuItemEnum;
import org.smartit.client.ui.pages.client.ClientCreate;
import org.smartit.client.ui.pages.client.ClientSearch;

/**
 * Class instance can not be created automatically because Class is not serializable
 * and Class.getInstance() method is not in JRE emulator library for GWT.
 * <p/>
 * The only way for instance Page Composite objects found is doing explicit Constructor calls,
 * which seems stupid (A better way should be found in the future).
 * <p/>
 * By now, we do it with this class.
 * <p/>
 * User: jose
 * Date: 24/11/13
 * Time: 18:42
 */
public class PageInstanceGetter {

    public static Composite getPageInstance(SubMenuItemEnum subMenuItemEnum) {
        switch (subMenuItemEnum) {
            case CreateClient:
                return new ClientCreate();
            case SearchClients:
                return new ClientSearch();
            case ImportClients:
                return new ClientSearch();
            case CreateService:
                return new ClientSearch();
            case SearchServices:
                return new ClientSearch();
            case MakeSale:
                return new ClientSearch();
            case SearchSales:
                return new ClientSearch();
            case MakePayment:
                return new ClientSearch();
            case SearchPayments:
                return new ClientSearch();
            default:
                return new ClientSearch();
        }
    }
}
